// 随机图片服务
export const getRandomImage = (width, height, category = '') => {
  const baseUrl = 'https://images.unsplash.com'
  const categories = {
    drama: [
      'photo-1529626455594-4ff0802cfb7e',
      'photo-1535713875002-d1d0cf377fde',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1438761681033-6461ffad8d80',
      'photo-1508214751196-bcfd4ca60f91',
      'photo-1518676590629-3dcbd9c5a5c9',
      'photo-1544725176-7c40e5a71c5e',
      'photo-1573496359142-b8d87734a5a2',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1536440136628-849c177e76a1'
    ],
    avatar: [
      'photo-1535713875002-d1d0cf377fde',
      'photo-1507003211169-0a1dd7228f2d',
      'photo-1438761681033-6461ffad8d80',
      'photo-1508214751196-bcfd4ca60f91'
    ]
  }

  const imageIds = categories[category] || categories.drama
  const randomId = imageIds[Math.floor(Math.random() * imageIds.length)]

  return `${baseUrl}/${randomId}?w=${width}&h=${height}&fit=crop`
}

// 统一卡片数据结构 - 所有卡片都应该返回这些字段
export const createUnifiedCard = (overrides = {}) => {
  return {
    // 基础信息
    id: '@id',
    title: '@ctitle(6, 15)',
    cover: () => getRandomImage(150, 200, 'drama'),

    // 描述信息
    description: '@cparagraph(1, 2)',

    // 集数信息
    currentEpisode: '@integer(1, 50)',
    totalEpisodes: '@integer(12, 100)',

    // 统计信息
    plays: '@integer(1000, 1000000)',

    // 标签信息
    badge: {
      'type|1': ['new', 'hot', 'exclusive'],
      'text|1': ['新剧', '爆剧', '独播']
    },
    tags: ['@cword(2, 4)', '@cword(2, 4)'],
    category: '@cword(2, 4)',

    // 用户交互状态
    isLiked: '@boolean',
    isStarred: '@boolean',

    // 观看进度
    progress: '@integer(0, 100)',
    status: 'watching',

    // 时间信息
    lastWatchTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
    duration: '@integer(1800, 7200)', // 30分钟到2小时

    // 合并覆盖的字段
    ...overrides
  }
}
